package com.bysj.yqsht.web.controller;

import com.bysj.yqsht.bean.MatchsAchievements;
import com.bysj.yqsht.bean.extend.MatchsAchievementsExtend;
import com.bysj.yqsht.service.IMatchAchievementsService;
import com.bysj.yqsht.service.impl.IMatchsAchievementsServiceImpl;
import com.bysj.yqsht.utils.Message;
import com.bysj.yqsht.utils.MessageUtil;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/matchAChievements")
@Api(description = "竞赛成果管理接口")
public class MatchsAchievementsController {
    @Autowired
    private IMatchsAchievementsServiceImpl matchsAchievementsService;


    @GetMapping("findAll")
    public Message findAll(){
        List<MatchsAchievements> MathsAchievements = matchsAchievementsService.findAll();
        return MessageUtil.success(MathsAchievements);
    }
    @GetMapping("findWithAll")
    public Message findWithAll(@RequestParam(defaultValue = "1") int pageNum, @RequestParam(defaultValue = "10") int limit) {
        List<MatchsAchievementsExtend> MatchsAchievementsExtend = matchsAchievementsService.findWithAll(pageNum,limit);
        return MessageUtil.success(MatchsAchievementsExtend);
    }
    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate (MatchsAchievements matchsAchievements){
        matchsAchievementsService.saveOrUpdate(matchsAchievements);
        return MessageUtil.success("修改或新增成功");
    }
    @GetMapping("deleteById")
    public Message deleteById (long id){
        matchsAchievementsService.deleteById(id);
        return MessageUtil.success("删除成功");
    }
    @GetMapping("findWithAllBy")
    public Message findWithAllBy(Long matchId,Long studentId){
        List<MatchsAchievementsExtend> list = matchsAchievementsService.findWithAllBy(matchId,studentId);
        return MessageUtil.success(list);
    }
}
